//脚步文件自动生成请勿改动！！！！！！！！

import SceneControl from "./script/SceneControl";


const { ccclass, property } = cc._decorator;

@ccclass
export default class MiguView extends cc.Component {

    static show: boolean = false;

    start() {
        let temp = cc.sys.localStorage.getItem("miguGameTime");
        if (temp) {
            temp = Number(temp);
        } else {
            temp = 0;
        }

        if (temp >= 3 || MiguView.show) {
            this.node.active = false;
            SceneControl.getInstance().node.opacity = 255;
        } else {
            MiguView.show = true;
            SceneControl.getInstance().node.opacity = 0;
            cc.systemEvent.targetOff(SceneControl.instance);
            cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this._keyDown, this);
        }
        temp++;
        cc.sys.localStorage.setItem("miguGameTime", temp);
    }

    private _keyDown() {
        this.node.active = false;
        SceneControl.getInstance().node.opacity = 255;
        cc.systemEvent.targetOff(this);
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, SceneControl.instance._keyDown, SceneControl.instance);
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, SceneControl.instance._keyUp, SceneControl.instance);
    }
}